<?php
//by willson 105328468@qq.com 2014/10/11
//index page interface

class category extends core {
	public $order_mod, $withdraw_mod;
	public function __construct() {
		parent::__construct();
		$this->order_mod = m("order");
		$this->withdraw_mod = m("withdraw");
	}

	//分类首页
	public function index(){
		//$pagesize = (isset($_GET['pagesize']) && trim($_GET['pagesize'])) ? intval($_GET['pagesize']) : 15;
		$sql ="SELECT * FROM jf_goods_category WHERE status='1' AND parent_id='0' 
			ORDER BY sort ASC, id ASC";
		$categories = $this->db->get_results($sql);
		if ($categories) {
			foreach ($categories as $k => $c) {
				$sql ="SELECT * FROM jf_goods_category WHERE status='1' AND parent_id='{$c->id}' 
					ORDER BY sort ASC, id ASC";
				$c->categories = $this->db->get_results($sql);
			}
		}
		success($categories);
	}
}
